<template>
	<view class="content">
		<view class="chop_bg">
			
		</view>
		<view class="chop_person_out">
			<view class="chop_person" >
				<view class="person_header" v-if="purchasePersons.persons">
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<text class="more">4</text>
					
				</view>
				<view class="count_font">
					{{purchasePersons.total||0}}人正在参与1元速砍活动
				</view>
			</view>
		</view>
		<view class="chop_record">
			<view class="chop_record_title">
				<view class="chop_record_title_lf">
					<image src="../../static/img/chop_jl.png" style="width: 24rpx;height: 27rpx;" mode=""></image>
					<text>砍成记录</text>
				</view>
				<text>已有{{bargainRecordObj.total||0}}人砍价</text>		
			</view>
			<view class="chop_record_content" v-if="bargainRecordObj.records.length">
				<view class="chop_record_content_item" >
					<view class="lf">
						<image src="../../static/img/bind_header.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
						<text>小白菜帮</text>
					</view>
					<text>砍掉35元</text>
				    
				</view>
				<view class="chop_record_content_item">
					<view class="lf">
						<image src="../../static/img/bind_header.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
						<text>小白菜帮</text>
					</view>
					<text>砍掉35元</text>
				    
				</view>
				<view class="chop_record_content_item">
					<view class="lf">
						<image src="../../static/img/bind_header.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
						<text>小白菜帮</text>
					</view>
					<text>砍掉35元</text>
				    
				</view>
				<view class="chop_record_content_item">
					<view class="lf">
						<image src="../../static/img/bind_header.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
						<text>小白菜帮</text>
					</view>
					<text>砍掉35元</text>
				    
				</view>
				
			</view>
			<view class="noData" v-else style="background-color: #FFFBEE;">
				找不到相关数据
			</view>
		</view>
		<view class="choping_box">
			<view class="chop_record_title">
				<view class="chop_record_title_lf">
					<image src="../../static/img/choping.png" style="width: 24rpx;height: 27rpx;" mode=""></image>
					<text>正在砍价</text>
				</view>
					
			</view>
			<view class="chop_product" v-if="seckillShopsEntityList.length">
				<view class="chop_product_item"  >
					<image src="../../static/img/gq.png" mode=""></image>
					<view class="img_price">
						<view >
							商品名称
						</view>
						<view >
							<text>￥24</text>
							<text>原价￥59</text>
						</view>
					</view>
				</view>
			   
			</view>
			<view class="noData">
				找不到相关数据
			</view>
		</view>
		
		<view class="rightOff_box">
			<view class="base_map">
				
			</view>
			<view class="rightOff_content">
				<view class="tab_box">
					<text v-for="(item,index) in list" :key="index" @click="changeTab(index)" :class="{'active':item.isClick}">{{item.title}}</text>
					
				</view>
				<template v-if="seckillShopsList.length">
					<view class="chop_product" 
					style="margin-top: 47rpx;" 
					v-for="(item,index) in seckillShopsList" 
					:key="index"
					@click="goDetail(item)"
					>
						<view class="chop_product_item" style="margin-bottom: 20rpx;">
							<image src="../../static/img/gq.png" mode=""></image>
							<view class="img_price">
								<view >
									{{item.shopTitle}}
								</view>
								<view >
									<text>￥{{item.shopDiscountPrice}}</text>
									<text>原价￥{{item.shopOriginalPrice}}</text>
								</view>
							</view>
						</view>
						
					</view>
				</template>
				
				<view class="noData" v-else>
					找不到相关数据
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				list:[{
					title:'正在疯狂砍',
					isClick:true,
				},{
					title:'马上开砍',
					isClick:false,
				}],
				purchasePersons:{},//砍价人
				seckillShopsEntityList:[],//正在砍价的商品；列表
				bargainRecordObj:{},//砍价记录数据
				index:0,
				pageRow:1,
				pageSize:10,
				seckillShopsList:[],//商品列表
				cityCode:'110101'
			}
		},
		onShow() {
			this.bargainFun();
			this.bargainRecordFun();
			this.seckillShops(this.index);
		},
		methods:{
			//详情
			goDetail(item){
				//type://1秒杀，2拼团 3砍价
				uni.navigateTo({
				    url: '../subjectSub/curriculum?id='+item.id+'&type=3'
				});
			},
			changeTab(index){
				this.index=index;
				this.list.forEach((a,i)=>{
					a.isClick=false;
					if(i==index){
						a.isClick=true;
					}
				})
				this.seckillShops(this.index);
			},
			// 砍价商品
			seckillShops(type){
				this.$http.get('/api/dream/seckillShops',{
					areaCode:this.cityCode,
					pageType:type,
					partition:2,
					pageRow:this.pageRow,
					pageSize:this.pageSize
				}).then((data)=>{
					if(data.data.code==200){
						if(data.data.result){
							this.seckillShopsList=data.data.result.records
						}else{
							this.seckillShopsList=[];
						}
						
					}else{
						this.seckillShopsList=[];
					}
				})
			},
		//获取砍价用户
			bargainFun(){
				this.$http.get('/api/dream/bargain',{}).then((data)=>{
					if(data.data.code==200){
					  if(data.data.result){
						  this.purchasePersons=data.data.result.purchasePersons||{};
						  this.seckillShopsEntityList=data.data.result.seckillShopsEntityList||[];
					  }	
					}
				})
			},
			//砍价记录
			bargainRecordFun(){
				this.$http.get('/api/dream/bargainRecord',{
					pageRow:1,
					pageSize:4
				}).then((data)=>{
					if(data.data.code==200){
					  if(data.data.result){
						  this.bargainRecordObj=data.data.result||{};
				
					  }	
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/helpChop.scss'
</style>
